{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}

<style type="text/css">
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
</style>

<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='1'}asdlkjasd{/eq}{/present}"
                           href="{:url('lists',['types'=>'1'])}{present name='status'}/status/{$status}{/present}">职业</a>
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='2'}asdlkjasd{/eq}{/present}"
                           href="{:url('lists',['types'=>'2'])}{present name='status'}/status/{$status}{/present}">经验</a>
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='6'}asdlkjasd{/eq}{/present}"
                           href="{:url('lists',['types'=>'6'])}{present name='status'}/status/{$status}{/present}">话题</a>
                    </div>
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='status'}{else /}asdlkjasd{/present}"
                            href="{:url('lists')}{present name='types'}/types/{$types}{/present}">所有</a>
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='0'}asdlkjasd{/eq}{/present}"
                            href="{:url('lists',['status'=>'0'])}{present name='types'}/types/{$types}{/present}">审核</a>
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='1'}asdlkjasd{/eq}{/present}"
                            href="{:url('lists',['status'=>'1'])}{present name='types'}/types/{$types}{/present}">通过</a>
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='-1'}asdlkjasd{/eq}{/present}"
                           href="{:url('lists',['status'=>'-1'])}{present name='types'}/types/{$types}{/present}">拒绝</a>
                    </div>
                    <div style="display:block;clear: both;"></div>
                    <div class="fixed-table-toolbar">
                        <form method="get" action="" style="display: flex;">
                            <div class="pull-left search" style="display: flex;">
                                <div class="columns columns-right btn-group pull-left">
                                    <select class="form-control" name="search">
                                        <option value="id" {php}if(input(
                                        '?param.search')){if(input('param.search')=='id'){echo "selected";}
                                        }{/php}>用户ID</option>
                                        <option value="phone" {php}if(input(
                                        '?param.search')){if(input('param.search')=='phone'){echo "selected";}
                                        }{/php}>手机</option>
                                        <option value="name" {php}if(input(
                                        '?param.search')){if(input('param.search')=='name'){echo "selected";}
                                        }{/php}>昵称</option>
                                        <option value="data" {php}if(input(
                                        '?param.search')){if(input('param.search')=='data'){echo "selected";}
                                        }{/php}>身份证号码</option>
                                    </select>
                                </div>

                                <div class="pull-right search">
                                    <input class="form-control input-outline" type="text"
                                           {php}
                                           if(input('?param.name')){
                                    if(input('param.name')){
                                    echo "value='".input('name')."'";
                                    }

                                    }
                                    {/php}
                                    name="name" placeholder="搜索">
                                </div>

                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px"
                                            class="btn btn-default btn-outline" type="submit">搜索
                                    </button>
                                </div>

                                {php}
                                if(input('?param.name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('lists')}">返回列表</a>
                                </div>
                                {php}
                                }
                                {/php}
                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                            <table data-toggle="table">
                                <thead>
                                <tr>
                                    <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">用户</th>
                                    <th data-align="center">管理</th>
                                    <th data-align="center">类别</th>
                                    <th data-align="center">标签</th>
                                    {neq name='types' value='6'}
                                    <th data-align="center">真人认证图</th>
                                    <th data-align="center">认证图A</th>
                                    <th data-align="center">认证图B</th>
                                    <th data-align="center">职称/职业</th>
                                    {/neq}
                                    <th data-align="center">状态</th>
                                    <th data-align="center">创建时间</th>
                                    <th data-align="center">更新时间</th>
                                </tr>
                                </thead>
                                <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.id}"></td>
                                    <td>
                                        <a onclick="member('{$v.user_id}')" style="color:#40BCF7">{$v.name}</a>
                                        <br/>({$v.user_id})
                                        <br/>({$v.sex})({$v.age})
                                    </td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">
                                                操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                <li><a onclick="add('{:url('edit',['id'=>$v['id'],'url'=>-1])}')">详情</a>
                                                <li class="divider"></li>
                                                <li><a onClick="lists({$v.id},-1)">拒绝</a></li>
                                                <li><a onClick="lists({$v.id},0)">审核</a></li>
                                                <li><a onClick="lists({$v.id},1)">通过</a></li>
                                                <li class="divider"></li>
                                                <li><a onClick="del({$v.id})" style="color:red">删除</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>

                                    <td>
                                        <a style="color:#40BCF7"  onclick="add('{:url('cateEdit',['id'=>$v['id'],'url'=>-1])}')">{if condition="$v.cate_name"}{$v.cate_name}{else}设置分类{/if}</a>
                                    </td>
                                    <td><a style="color:#40BCF7"  onclick="add('{:url('categoryEdit',['id'=>$v['id'],'url'=>-1])}')">{$v.category_name}</a></td>
                                    {neq name='types' value='6'}
                                    {php}
                                    $urlhead = _ossUrl($v['oss_idx']);
                                    {/php}
                                    <td>
                                        <a onclick="showpic('{:strpos($v.face, 'http')===false?$urlhead:''}{$v.face}')">
                                            <img style="max-width:100px" src="{:strpos($v.face, 'http')===false?$urlhead:''}{$v.face}"/>
                                        </a>
                                    </td>
                                    <td>
                                        <a onclick="showpic('{:strpos($v.img_a, 'http')===false?$urlhead:''}{$v.img_a}')">
                                            <img style="max-width:100px" src="{:strpos($v.img_a, 'http')===false?$urlhead:''}{$v.img_a}"/>
                                        </a>
                                    </td>
                                    <td>
                                        <a onclick="showpic('{:strpos($v.img_b, 'http')===false?$urlhead:''}{$v.img_b}')">
                                            <img style="max-width:100px" src="{:strpos($v.img_b, 'http')===false?$urlhead:''}{$v.img_b}"/>
                                        </a>
                                    </td>
                                    <td>{$v.occupation}</td>
                                    {/neq}
                                    <td id="hide{$v.id}">
                                        {switch name="v.status"}
                                            {case value="-1"}<span class="btn btn-primary btn-xs" style="background-color:#585858;border-color:#585858">拒&nbsp;&nbsp;&nbsp;绝</span><br />{$v.reason}{/case}
                                            {case value="0"}<span class="btn btn-default btn-xs">审&nbsp;&nbsp;&nbsp;核</span>{/case}
                                            {case value="1"}<span class="btn btn-primary btn-xs">通&nbsp;&nbsp;&nbsp;过</span>{/case}
                                        {/switch}
                                    </td>
                                    <td>
                                        <span {if condition="date('Ymd')==date('Ymd',strtotime($v.create_time))"}style="color: #ed5565"{/if}>{$v.create_time}</span>
                                    </td>
                                    <td>
                                        <span {if condition="date('Ymd')==date('Ymd',strtotime($v.audit_time))"}style="color: #ed5565"{/if}>{$v.audit_time}</span>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-6 loadClick">
                    <a  class="btn btn-outline btn-default" onclick="alla(1)">
                        批量通过
                    </a>
                    <a  class="btn btn-outline btn-default" onclick="alla(-1)">
                        批量拒绝
                    </a>
                    <a  class="btn btn-outline btn-default" onclick="alla(0)">
                        批量审核
                    </a>
                </div>
                <div class="col-sm-6 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>

{include file="public/footer" /}
{load href="__PLUGINS__iCheck/icheck.min.js"}
{load href="__PLUGINS__iCheck/custom.css"}

<script type="text/javascript">

    $(document).ready(function(){
        $('#delidAll').click(function(){
            $('input[type=checkbox]').each(function(){
                var self=$(this);
                if(!self.prop('checked')){
                    self.prop('checked',true);
                }else{
                    self.prop('checked',false);
                }
            });
        })
    });
    // 跳转用户信息
    function member(id)
    {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("member/index")}?search=id&name='+id
            });
        });
    }

    function del(id)
    {
        swal_del(id, "{:url('Del')}")
    }

    function lists(id,status)
    {
        if (status == -1) {
            layer.prompt({title: '拒绝原因', formType: 2}, function(text, index){
                var reason = text;

                ajaxFun("post","{:url('Edit')}",{id:id,status:status,reason:reason},'json',function(ret){
                    if(ret){
                        if(ret.ret){
                            layer.msg(ret.ret)
                            window.location.reload()
                        }else{
                            layer.msg(ret.err)
                        }
                    }else{
                        swal_msg("错误",ret,"error");
                    }
                })
            });
        } else {
            ajaxFun("post","{:url('Edit')}",{id:id,status:status},'json',function(ret){
                if(ret){
                    if(ret.ret){
                        layer.msg(ret.ret)
                        window.location.reload()
                    }else{
                        layer.msg(ret.err)
                    }
                }else{
                    swal_msg("错误",ret,"error");
                }
            })
        }
    }

    function watch(id)
    {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("Watch")}?id='+id
            });
        });
    }
    
    function showpic(pic) {
        window.open(pic)
    }


    function alla(types){
        var all=$(".form-horizontal").serialize();
        var alls=$(".form-horizontal").serializeArray();

        ajaxFun("post",'{:url('attestation/shenheAll')}?type='+types,all,'json',function(ret){

            if(ret){
                var text
                switch(types)
                {
                    case -1:
                        text = '<span class="btn btn-primary btn-xs" style="background-color: #414141;border-color:#414141">拒 绝</span>';
                        break;
                    case 0:
                        text = '<span class="btn btn-default btn-xs">审 核</span>';
                        break;
                    case 1:
                        text = '<span class="btn btn-primary btn-xs">通 过</span>';
                        break;
                    case 2:
                        text = '<span class="btn btn-primary btn-xs">通 过</span>';
                        break;
                }
                for(var i=0;i<alls.length;i++){
                    if(types=='del'){
                        $('#id'+alls[i]['value']).remove();
                    }else{
                        $('#hide'+alls[i]['value']).html(text);
                    }
                }
                layer.closeAll('loading'); 
                swal_msg('操作成功')
            }
        })

    }
</script>
